<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<h:head>
	<title>Distributor admin</title>
	<link type="text/css" rel="stylesheet" href="css/dth.css" />
	<style>
.myTable td:nth-child(1) {
	width: 25px;
}

.admin_menu_distibute {
	background: #0FD1D1 !important;
}

.feild-input {
	float: left;
	margin-bottom: 4px;
	margin-top: 4px;
	width: 100%;
}

.feild-input label {
	float: left;
	margin-right: 4px;
	text-align: right;
	width: 20%;
}

.feild-action {
	width: 100%;
	height: 20%;
	float: right;
}

.feild-action button {
	float: right;
	margin-right: 5px;
}
</style>
</h:head>

<h:body>
	<p:ajaxStatus
		style="bottom: 68%;
	    height: 32px;
	    position: fixed;
	    right: 50%;
	    width: 32px;
	    z-index: 99999;">
		<f:facet name="start">
			<p:graphicImage value="images/loading.gif" />
		</f:facet>

		<f:facet name="complete">
			<h:outputText value="" />
		</f:facet>
	</p:ajaxStatus>
	<p:growl id="growl" showDetail="true" sticky="false" />
	<ui:insert name="header">
		<ui:include src="/header/header_dth.xhtml" />
	</ui:insert>
	<div>
		<div class="dth_body_home">
			<ui:insert name="header_banner">
				<ui:include src="/header/header_banner.xhtml" />
			</ui:insert>
			<div class="dth_content">
				<div class="dth_admin_menu">
					<h:form>

						<ui:insert name="header_banner">
							<ui:include src="/header/menu_admin.xhtml" />
						</ui:insert>

					</h:form>
				</div>
				<div class="dth_content_admin">
					<div class="menu_top1">
						<h:form id="dlgform">
							<p:dialog header="#{msg['header_insert']} #{msg['menu_admin_distributor']}"
								widgetVar="dlg" id="dlg" width="500" height="120"
								resizable="false">
								<h:panelGroup id="dlgisert">
									<h:inputHidden value="#{distributorBean.id}"></h:inputHidden>
									<div class="feild-input">
										<h:outputLabel value="#{msg[name]}"></h:outputLabel>
										<h:inputText value="#{distributorBean.name}"></h:inputText>
									</div>
									<div class="feild-action">
										<p:commandButton value="#{msg['btn_ok']}"
											oncomplete="dlg.hide()" action="#{distributorBean.insert}"
											update=":mainform,:growl"></p:commandButton>
										<p:commandButton value="#{msg['btn_cancel']}"
											oncomplete="dlg.hide()"></p:commandButton>
									</div>
								</h:panelGroup>
							</p:dialog>
						</h:form>
						<h:form id="form_confirm_delete_distributor">
							<p:confirmDialog id="confirm_delete_distributor"
								message="#{msg['delete_mess']}"
								header="#{msg['header_warning']}" width="400" showEffect="clip"
								closable="false" widgetVar="confirm_del_distributor">
								<h:panelGroup id="data">
									<h:inputHidden value="#{distributorBean.id}"></h:inputHidden>
									<div class="feild-action">

										<p:commandButton value="#{msg['btn_no']}"
											onclick="confirm_del_distributor.hide()"></p:commandButton>
										<p:commandButton style="float: right"
											value="#{msg['btn_yes']}" action="#{distributorBean.delete}"
											onclick="confirm_del_distributor.hide()" update=":mainform"></p:commandButton>
									</div>
								</h:panelGroup>
							</p:confirmDialog>
						</h:form>
						<h:form>
							<p:commandButton onclick="dlg.show()" title="insert"
								icon="ui-icon ui-icon-plusthick" update=":dlgform:dlgisert"></p:commandButton>
							<h:outputText value="Distributor"
								style="margin-left:5px;font-size: 20px;font-weight: bold;"></h:outputText>
						</h:form>
					</div>
					<div class="dth_admin_main">
						<h:panelGroup id="mainform">
							<h:form>
								<p:dataTable styleClass="myTable" var="item"
									value="#{distributorBean.listDistributor}" rowIndexVar="row">
									<p:column headerText="Stt">
										<h:outputText value="#{row+1}" />
									</p:column>
									<p:column headerText="#{msg['name']}">
										<h:outputText style="float:left;"
											value="#{item.distributorName}">
										</h:outputText>
									</p:column>

									<p:column headerText="#{msg['date_insert']}">
										<h:outputText style="float:left;" value="#{item.dateInsert}">
										</h:outputText>
									</p:column>
									<p:column headerText="#{msg['menu_action']}">
										<h:form style="text-align: center;">
											<p:commandLink onclick="confirm_del_distributor.show()"
												update=":form_confirm_delete_distributor:data">
												<f:param value="delete" name="action"></f:param>
												<f:param value="#{item.distributorId}" name="distributor_id"></f:param>
												<img src="images/icon_delete.png" title="#{msg['btn_delete']}" />
											</p:commandLink>
											<p:commandLink onclick="dlg.show()"
												update=":dlgform:dlgisert">
												<f:param value="update" name="action"></f:param>
												<f:param value="#{item.distributorId}" name="distributor_id"></f:param>
												<img src="images/icon_edit.png" title="#{msg['btn_edit']}" />
											</p:commandLink>

										</h:form>
									</p:column>
								</p:dataTable>
							</h:form>
						</h:panelGroup>
					</div>
				</div>
			</div>
		</div>
	</div>
	<ui:insert name="footer">
		<ui:include src="/footer/footer_dth.xhtml" />
	</ui:insert>
</h:body>
</html>